<%@ page language="java" pageEncoding="UTF-8"%>

<table id="phoneTable" class="table table-striped cms-table">
	<thead>
		<tr>
			<th>登录号码</th>
			<th>登录时间</th>
			<th>手机唯一标识</th>
			<th>SIM卡唯一标识</th>
		</tr>
	</thead>
	<tbody>
	</tbody>
</table>

<table id="phoneTemplate" class="hide">
  	<tr>
	    <td></td>
	    <td></td>
	    <td></td>
	    <td></td>
  	</tr>
</table>

<script type="text/javascript">
function listPhone(){
	$.ajax({
    	type: "GET",
    	cache: false,
    	url: ctx + "/biz/system/user/phone.json",
    	data: {userId: $("#userId").val()},
    	dataType:"json",
    	success:function(json) {
    		if (!json.succeed) {
    			return;
    		}
    		buildPhoneList(json.data);
    	},
		error: function(message) {
		}
	});
}

function buildPhoneList(data){
	if(data.length == 0){
		return;
	}
	$("#phoneSummary").html("("+data.length+")"); 
	$(data).each(function(index, item) {
		buildPhoneTd(item).appendTo($("#phoneTable").find("tbody"));
	});
}

function buildPhoneTd(item){
	var taskEle = $("#phoneTemplate").clone();
	taskEle.find("tr").attr("id", "item" + item.id);
	var tdList = taskEle.find("td");
	$(tdList.get(0)).text(item.mobile);
	$(tdList.get(1)).text(item.loginTime);
	$(tdList.get(2)).text(item.imei);
	$(tdList.get(3)).text(item.imsi);
	
	return taskEle.find("tr");
}

$(document).ready(function() {
	listPhone();
});
</script>